<?php
declare (strict_types = 1);

namespace app\adminapi\controller;

use think\Request;

class Linkage
{
    /**
     * 多级联动
     */
    public function linkage(){
        # 查询出来顶级分类
        $category = \app\common\model\Category::where('pid','=',0)->select();

        return view('',['category' => $category]);
    }

    /**
     * 根据父级id获取对应子级
     */
    public function getChildCategory(){
        $p_id = \request()->post('p_id');
        # 查询出来顶级分类
        $category = \app\common\model\Category::where('pid','=',$p_id)->select();

        return json(['data' => $category,'msg' => 'ok','code' => 200]);
    }
}
